package ramosmanuales.data.xml;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import ramosmanuales.util.Quincena;

@XmlRootElement(name = "pago")
@XmlType(propOrder = {"anioIni", "qnaIni", "anioFin", "qnaFin", "importe", "quincenas", "pagoTotal"})
public class Pago {
    private String anioIni;
    private String qnaIni;
    private String anioFin;
    private String qnaFin;
    private String importe;
    private String quincenas;
    private String pagoTotal;

    @XmlElement(name = "anioIni")
    public String getAnioIni(){
        return anioIni;
    }

    public void setAnioIni(String anioIni){
        this.anioIni = anioIni;
    }

    @XmlElement(name = "qnaIni")
    public String getQnaIni(){
        return qnaIni;
    }

    public void setQnaIni(String qnaIni){
        this.qnaIni = qnaIni;
    }

    @XmlElement(name = "anioFin")
    public String getAnioFin(){
        return anioFin;
    }

    public void setAnioFin(String anioFin){
        this.anioFin = anioFin;
    }

    @XmlElement(name = "qnaFin")
    public String getQnaFin(){
        return qnaFin;
    }

    public void setQnaFin(String qnaFin){
        this.qnaFin = qnaFin;
    }

    @XmlElement(name = "importe")
    public String getImporte(){
        return importe;
    }

    public void setImporte(String importe){
        this.importe = importe;
    }

    @XmlElement(name = "quincenas")
    public String getQuincenas(){
        return quincenas;
    }

    public void setQuincenas(String quincenas){
        this.quincenas = quincenas;
    }

    @XmlElement(name = "pagoTotal")
    public String getPagoTotal(){
        return pagoTotal;
    }

    public void setPagoTotal(String pagoTotal){
        this.pagoTotal = pagoTotal;
    }

    public Quincena getRangoIni(){
        if(anioIni!=null&&qnaIni!=null)
            return new Quincena(Integer.parseInt(anioIni), Integer.parseInt(qnaIni));
        else
            return new Quincena();
    }

    public Quincena getRangoFin(){
        if(anioFin!=null&&qnaFin!=null)
            return new Quincena(Integer.parseInt(anioFin), Integer.parseInt(qnaFin));
        else
            return new Quincena();
    }

    public Object[] getElements(){
        return new Object[] {anioIni, qnaIni, anioFin, qnaFin, importe, quincenas, pagoTotal};
    }

    public Object[] getElementsRange(){
        return new Object[] {getRangoIni().toString(), getRangoFin().toString(), importe, quincenas, pagoTotal};
    }

    public boolean equals(Pago pago){
        if(this.anioIni.equals(pago.anioIni) && this.qnaIni.equals(pago.qnaIni) && this.anioFin.equals(pago.anioFin)
                && this.qnaFin.equals(pago.qnaFin) && this.importe.equals(pago.importe) && this.quincenas.equals(pago.quincenas)
                    && this.pagoTotal.equals(pago.pagoTotal))
            return true;
        
        return false;
    }
}